package com.zfh;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 1.直接继承HttpServlet类，编写用户需要的Serlvet【类，组件，控制器】<br>
 * <li> Servlet接口
 * <li> GenericServlet抽象类
 * <li> HttpServlet类<br>
 * 2.采用了注解的配置方式，最简单的注解，只给出url-pattern即可，建议统一用小写<br>
 * 3.所有的命名建议和要求：见名知义，英文
 * 
 */
@WebServlet("/servletdemo01")
public class ServletDemo01 extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * <li>构造函数
     */
    public ServletDemo01() {
        super();
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// 直接输出到浏览器的文本
		response.getWriter().append("Served at: ").append(request.getContextPath());
		response.getWriter().append("hello,fhzheng");
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// 转交给doGet处理
		doGet(request, response);
	}

}
